import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@SuppressWarnings("serial")
public class SingleSlider extends JPanel 
{
	private Node colorNode;
	private Demo win;
	private JSlider slider;
	public SingleSlider(Node num,String colorLabel,Demo window)
	{
		win=window;
		colorNode=num;
		setLayout(new GridLayout(0,1));
		JLabel label=new JLabel(colorLabel,JLabel.CENTER);
		add(label);
		label.setVerticalAlignment(3);
		slider=new JSlider(JSlider.VERTICAL,0,255,0);
		slider.addChangeListener(new SliderListener());
		slider.setMajorTickSpacing(15);
		slider.setMinorTickSpacing(2);
		slider.setPaintTicks(true);
		slider.setPaintLabels(true);
		add(slider);
	}
	private class SliderListener implements ChangeListener
	{
		public void stateChanged(ChangeEvent e)
		{
			colorNode.setNode(slider.getValue());
			win.changeColor();
		}
	}
}
